package com.hgc.ch01.threadlocal;

/**
 * Created by 01367627 on 2019/6/14.
 */
public class ThreadLocalExample {

    private static ThreadLocal<String> threadLocal = new ThreadLocal<String>();

    private static class MyThread extends Thread{

        public MyThread(String name){
            setName(name);
        }

        @Override
        public void run() {
            threadLocal.set(getName());
            System.out.println(threadLocal.get());
        }
    }

    public static void main(String[] args) {
        Thread james = new MyThread("James");
        Thread Lison = new MyThread("Lison");
        james.start();
        Lison.start();
    }



}
